package com.bitters.fileupload.config;

import com.bitters.fileupload.common.file.MyCustomMultipartResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.web.multipart.MultipartResolver;

/**
 * @author thomashe
 * @date 2022/5/30
 **/

@Configuration
@Order(1)
public class MyMultipartConfig {

    @Bean(name = "multipartResolver")
    public MultipartResolver multipartResolver() {
        MyCustomMultipartResolver resolver = new MyCustomMultipartResolver();
        resolver.setDefaultEncoding("UTF-8");
        //resolveLazily属性启用是为了推迟文件解析
        resolver.setResolveLazily(true);
        resolver.setMaxInMemorySize(40960);
        //上传文件大小 1024M 50*1024*1024
        resolver.setMaxUploadSize(1024 * 1024 * 1024);
        return resolver;
    }
}
